//
//  MainViewController.swift
//  XJWeiBo
//
//  Created by 徐健 on 16/3/7.
//  Copyright © 2016年 徐健. All rights reserved.
//




import UIKit

class MainViewController: UITabBarController {
    

    

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
//        print(tabBar.classForCoder)
        setValue(MainTabBar(), forKey: "tabBar")
//        print(tabBar.classForCoder)
        
        addChildViewControllers()


    }
    
    
    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    
    
    private func addChildViewController(vc:UITableViewController,title:String,imageName:String){
        
//        vc.tabBarItem.title = title
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
//        tabBar.tintColor = UIColor.orangeColor()
        
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.imageWithRenderingMode(.AlwaysOriginal)
        
        let nav = UINavigationController(rootViewController: vc)
        
//        vc.navigationItem.title = title
        
        addChildViewController(nav)
        
        
    }



}
